package com.business.lgh.naocs.naming.core.pojo;

import com.business.lgh.nacos.api.naming.pojo.Instance;
import com.business.lgh.naocs.naming.constant.UtilsAndCommons;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

/**
 * @author lgh
 * @version V1.0
 * @Package com.business.lgh.naocs.naming.core
 * @date 2020/6/23 12:22 下午
 */
@JsonInclude(JsonInclude.Include.NON_NULL) //返回的内容不要有null，可以有空字符之类的（属性为空的不参与序列化）
@Data
public class InstanceWrapper extends Instance {

    /**
     * 心跳时间
     */
    private volatile long beatTime=System.currentTimeMillis();

    @JsonIgnore
    public String getDatumKey() {
        if (getPort() > 0) {
            return getIp() + ":" + getPort() + ":" + UtilsAndCommons.LOCALHOST_SITE + ":" + getClusterName();
        } else {
            return getIp() + ":" + UtilsAndCommons.LOCALHOST_SITE + ":" + getClusterName();
        }
    }

}
